#ifndef _CNN_OPERATION_H
#define _CNN_OPERATION_H

#include "config.h"


/*输入矩阵结构体*/
typedef struct InoutputData{
	int iCol;      /*列*/  
	int iRow;     /*行*/
	int iDim;        /*维数 通道数*/
	// int iLineBytes;  /**/
	// int iTotalBytes; 
	float ***pppfDatas;   /*像素数据，三维数组pppfDatas[iDim][iRow][iCol]*/ 
}T_InoutputData,*PT_InoutputData;

/*参数描述结构体*/
typedef struct Kernel{
    char *name;
    char *ParamsPathInH5;
	int iNum;                   /*数量*/
	int iDim;			        /*维数*/
    int iRow;                   /*行*/
    int iCol;                   /*列*/
    int iBiasLength;            
    //unsigned long ulTotalBytes; 
	float *pfKernelBias;        /*偏置参数*/
    float ****ppppfKernelParams;    /*参数，四维数组ppppfKernelParams[iRow][iCol][iDim][iNum]*/
}T_KernelParams,*PT_KernelParams;


int ModelParamsInit(PT_KernelParams ptKernelParams,int iNumOfLayer,char* pcModelPath);

void ModelParamsFree(PT_KernelParams ptKernelParams,int iNumOfLayer);

/*卷积层*/
PT_InoutputData Convolution2D(PT_InoutputData ptInputData, PT_KernelParams ptKernelParams, int iStrides, int iPadding);
/*全连接层*/
PT_InoutputData Dense(PT_InoutputData ptInputData,PT_KernelParams ptKernelParams);
/*池化*/
PT_InoutputData PoolOperation(PT_InoutputData ptInputData, int iStrides, int iPadding, int iPoolSize, int iPoolSelect);

/*Flatten操作*/
PT_InoutputData Flatten(PT_InoutputData ptInputData);

/*relu激活函数*/
void ActivationRelu(PT_InoutputData ptInputData);
/*softmax函数*/
void ActivationSoftmax(PT_InoutputData ptInputData);
/*Tanh函数*/
void ActivationTanh(PT_InoutputData ptInputData);

/*Dropout函数*/
void Dropout(PT_InoutputData ptInputData, float fDropoutRate);

void MallocInoutputDatas(PT_InoutputData ptInoutputData);

void FreeInoutputDatas(PT_InoutputData ptInoutputData);

#endif